package 字符串;

import java.util.Arrays;
import java.util.Scanner;

public class 最长连续递增子序列 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int[] res=new int[n];
        for(int i=0;i<n;i++)
            res[i]=sc.nextInt();
        System.out.println(getMaxlength(res));

    }

    public static int getMaxlength(int[] A) {
        int size=A.length;
        if (size <= 0)
            return 0;
        int index = 0;
        int res = 1;
        int current = 1;
                for (int i = 1; i < size; i++) {
                    if (A[i] > A[i - 1]) {
                        current++;
                    } else {
                        if (current > res) {
                            index = i;
                            res = current;
                        }
                        current = 1;
            }
        }
        int[] B =new int[A.length];
        for (int i = 0; i < A.length; i++) {
            B[i] = A[i];
        }
        Arrays.sort(A);
        if (Arrays.equals(A,B)){
            res = current;
            for (int i = 0; i < A.length; i++) {
                System.out.print(A[i]+" ");
            }
        }else {
            for (int i = index-res; i < index; i++) {
                System.out.print(B[i]+" ");
            }
        }

        System.out.println();
        return res;
    }

}